import Vue from 'vue'
import App from './App.vue'
import router from '@/router';
import store from '@/store';
import TypeNav from '@/components/TypeNav';
import Carousel from '@/components/Carousel';
import Pagination from '@/components/Pagination';
import '@/mock/mockServe';
import VueLazyload from 'vue-lazyload'

// 引入swiper样式
import "swiper/css/swiper.css";

// 引入全局请求api 挂载到vue原型上 只引入一次使其处处使用
import * as API from '@/api';

// 按需引入element-ui 
import { Button,MessageBox} from 'element-ui';

// 引入自定义插件 使用 v-upper="msg" 将内容转换为大写
import myPlugin from '@/plugins/myPlugin';

Vue.use(myPlugin,{
  name: 'upper'
});

// 不同得注册方式
Vue.use(Button);
Vue.prototype.$msgbox = MessageBox;
Vue.prototype.$alert = MessageBox.alert;

// 注册全局组件
Vue.component(TypeNav.name,TypeNav);
Vue.component(Carousel.name,Carousel);
Vue.component(Pagination.name,Pagination);

import loadImage from '@/assets/loading.gif'
Vue.use(VueLazyload,{
  preLoad: 1.3,
  loading: loadImage,
  error: loadImage,
  attempt: 1
})

//引入表单校验插件
import "@/plugins/validate";

new Vue({
  render: h => h(App),
  // 配置全局是事件总线
  beforeCreate() {
    Vue.prototype.$bus = this;
    Vue.prototype.$API = API;
  },
  router,
  store
}).$mount('#app')
